<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--引入Vue-->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>

<div id="app">
    <div>获取当前时间: {{getCurrentDate1()}}</div>
    <div>获取当前时间: {{getCurrentDate2}}</div>
</div>

<script type="text/javascript">

    /**
     * vm.getCurrentDate1()
     "1,582,558,634,170"
     vm.getCurrentDate1()
     "1,582,558,640,378"
     vm.getCurrentDate1()
     "1,582,558,641,074"
     vm.getCurrentDate2
     "1,582,558,616,278"
     vm.getCurrentDate1()
     "1,582,558,656,377"
     vm.getCurrentDate2
     "1,582,558,616,278"
     vm.getCurrentDate2
     "1,582,558,616,278"
     vm.getCurrentDate2
     "1,582,558,616,278"
     vm.getCurrentDate2
     "1,582,558,616,278"
     vm.getCurrentDate2
     "1,582,558,616,278"
     可以看出函数一直在变  计算属性的缓存下来了 提高效率
     * @type {Vue}
     */
    var vm = new Vue({
        el: "#app",
        methods: {
          getCurrentDate1:function () {
            return Date.now().toLocaleString();
          }
        },
        /*第一次计算 走cpu  第二次保存下来缓存  vue特有的计算属性*/
        computed: {
            getCurrentDate2: function () {
                return Date.now().toLocaleString();
            }
        }
    });
</script>

</body>
</html>